Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_InertialSensor: Murata SCH16T IMU #26876

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dakejahl
Copy link
Contributor

Still need to validate on hardware. I can't tell if the IMU driver is running or not, is there anyway to quickly validate sensors on the bench? Using hal.console->printf() and printf() doesn't output anything on the debug uart.

Any suggestions for the best way to validate a new IMU?

  • validate data
  • validate loop rate
  • validate missing samples (failed CRC, missed DRDY)
  • validate driver runs without restarting (no failed register config, no failed data reads)

You can see where I added printfs at. I'm taking off for the day but when I'm back I'll keep looking around.

@rmackay9
Copy link
Contributor

Hi @dakejahl,

Thanks for this. I'll leave it for others to answer your questions but I've noticed a couple of small things that will need fixing:

  1. could you split the larger commit into multiple commits separated by directory? In general commits should only affect a single subsystem and we do this because it makes backporting much easier.
  2. could you rebase on master? It looks like a PR from yesterday changed Tools/scripts/decode_devid.py file.

Thanks again

@dakejahl dakejahl closed this Apr 24, 2024
@dakejahl dakejahl force-pushed the pr-murata_sch16t_imu branch from 62727a0 to 0eded27 Compare April 24, 2024 04:40
@dakejahl dakejahl deleted the pr-murata_sch16t_imu branch April 24, 2024 04:42
@dakejahl dakejahl reopened this Apr 24, 2024
@dakejahl dakejahl marked this pull request as draft April 24, 2024 04:58
@dakejahl dakejahl force-pushed the pr-murata_sch16t_imu branch from 18b2691 to 2a1da7f Compare April 24, 2024 05:10
Copy link
Collaborator

@andyp1per andyp1per left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main thing you need to do is restructure to use register_periodic_callback rather than creating a new thread

libraries/AP_HAL_ChibiOS/hwdef/ARKV6X/hwdef.dat Outdated Show resolved Hide resolved
libraries/AP_InertialSensor/AP_InertialSensor_SCH16T.cpp Outdated Show resolved Hide resolved
libraries/AP_InertialSensor/AP_InertialSensor_SCH16T.cpp Outdated Show resolved Hide resolved
libraries/AP_InertialSensor/AP_InertialSensor_SCH16T.cpp Outdated Show resolved Hide resolved
libraries/AP_InertialSensor/AP_InertialSensor_SCH16T.cpp Outdated Show resolved Hide resolved
libraries/AP_InertialSensor/AP_InertialSensor_SCH16T.cpp Outdated Show resolved Hide resolved
libraries/AP_InertialSensor/AP_InertialSensor_SCH16T.cpp Outdated Show resolved Hide resolved
@dakejahl
Copy link
Contributor Author

Alright I am using register_periodic_callback now, for the time delays between states I am using adjust_periodic_callback to set the next callback time, is this the correct way to do it? Should I even use the drdy pin? I don't see any examples of IMU drivers using it with an interrupt callback for scheduling the read

@andyp1per
Copy link
Collaborator

Alright I am using register_periodic_callback now, for the time delays between states I am using adjust_periodic_callback to set the next callback time, is this the correct way to do it? Should I even use the drdy pin? I don't see any examples of IMU drivers using it with an interrupt callback for scheduling the read

and yes those two functions are the correct way to adjust the period if you need to

@dakejahl dakejahl force-pushed the pr-murata_sch16t_imu branch from 11017c6 to de107a1 Compare April 30, 2024 22:03
@dakejahl
Copy link
Contributor Author

dakejahl commented May 1, 2024

@andyp1per Thanks for the help with this. I've tested this successfully and am ready for final review. You can ignore the hwdef file since those changes are just for testing. If there's anything else in the driver to change let me know. If it looks good I'll rebase on master and re-commit each file.

Copy link
Collaborator

@andyp1per andyp1per left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to converge on filters and speeds suitable for ArduPIlot

libraries/AP_InertialSensor/AP_InertialSensor_SCH16T.cpp Outdated Show resolved Hide resolved
libraries/AP_InertialSensor/AP_InertialSensor_SCH16T.cpp Outdated Show resolved Hide resolved
_registers[0] = RegisterConfig(CTRL_FILT_RATE, FILTER_68HZ); // 68Hz -- default
_registers[1] = RegisterConfig(CTRL_FILT_ACC12, FILTER_68HZ); // 68Hz -- default
_registers[2] = RegisterConfig(CTRL_FILT_ACC3, FILTER_68HZ); // 68Hz -- default
_registers[3] = RegisterConfig(CTRL_RATE, RATE_300DPS_1475HZ); // +/- 300 deg/s, 1600 LSB/(deg/s) -- default, Decimation 8, 1475Hz
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You really want to read at the highest rate you can if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I validate CPU usage? In PX4 1475Hz uses 15% CPU. My concern is higher update rates means more CPU and higher required SPI rate

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see by building with --enable-stats and looking at @SYS/threads.txt

@dakejahl
Copy link
Contributor Author

dakejahl commented May 3, 2024

@andyp1per I agree with you on the update rate and filter settings, we need to do more testing to determine the best settings. I could create a parameter that configures the rate and filter settings, is this an acceptable thing to do in ardupilot? In PX4 some drivers expose parameters so the user can tweak things like this. We're developing this driver for Murata, but we don't have it integrated into a product yet so our flight testing has been limited. We flew it on PX4 and it worked well. The other consideration is SPI bus speed, at higher update rates we'd need to increase the bus speed, but right now on my frame it's external with kinda long wires.

Ideally I'd like to get this merged just to get it in and we can come back to fine tuning the settings once we have it properly integrated on a frame. Does this work?

@dakejahl dakejahl force-pushed the pr-murata_sch16t_imu branch from 289d6f5 to ae78619 Compare May 13, 2024 23:55
@dakejahl
Copy link
Contributor Author

I've disabled the filter and rebased/squashed on master. The last outstanding question is regarding update rate.
image

@dakejahl dakejahl marked this pull request as ready for review May 14, 2024 00:05
@andyp1per
Copy link
Collaborator

@andyp1per I agree with you on the update rate and filter settings, we need to do more testing to determine the best settings. I could create a parameter that configures the rate and filter settings, is this an acceptable thing to do in ardupilot? In PX4 some drivers expose parameters so the user can tweak things like this. We're developing this driver for Murata, but we don't have it integrated into a product yet so our flight testing has been limited. We flew it on PX4 and it worked well. The other consideration is SPI bus speed, at higher update rates we'd need to increase the bus speed, but right now on my frame it's external with kinda long wires.

Ideally I'd like to get this merged just to get it in and we can come back to fine tuning the settings once we have it properly integrated on a frame. Does this work?

Generally we don't want to do it like that - we want evidence that it works successfully on a flying vehicle complete with a log. Don't want to include code that isn't going to practically work 😄

@andyp1per
Copy link
Collaborator

I've disabled the filter and rebased/squashed on master. The last outstanding question is regarding update rate. image

On most drivers we read at 8Khz and then downsample to the backend rate (which is configurable via INS_GYRO_RATE). This is perfectly acceptable CPU-wise. Some of the Invensense are 9Khz. If you look at the Invensensev3 driver which is our most actively maintained you can see how this is done.

@peterbarker
Copy link
Contributor

Ping @dakejahl .... got some dataflash logs from a flying Copter?

@dakejahl
Copy link
Contributor Author

@peterbarker thanks for the follow up. No I don't have any logs yet. This driver integration has fallen to the bottom of my priority list. We're waiting on some higher range versions of the chip anyway, which are more suitable for drones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants